define(["jquery", "easy-admin"], function ($, ea) {
    var hash = ea.getDataBrage('hash');
    var id = ea.getDataBrage('id');
    var type = ea.getDataBrage('type');
    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'system.Apifieldlist/index?id='+id+"&type="+type,
        add_url: 'system.Apifieldlist/add?hash='+hash+"&type="+type,
        edit_url: 'system.Apifieldlist/edit',
        delete_url: 'system.Apifieldlist/delete',
        modify_url: 'system.Apifieldlist/modify',
        export_url: 'system.Apifieldlist/export',
    };
    var Controller = {

        index: function () {

            ea.table.render({
                init: init,
                cols: [[
                    // 字段名称	字段说明	数据类型	是否必须	默认值
                    { type: "checkbox" },
                    { field: 'id', width: 20, title: 'ID' },
                    { field: 'fieldname', minWidth: 40, title: '字段名称', edit: 'text' },
                    { field: 'info', minWidth: 40, title: '字段说明', edit: 'text' },
                    { field: 'datatype', minWidth: 80, title: '数据类型' },
                    { field: 'ismust', title: '是否必须', width: 120 , search: 'select',selectList: { 0: '否', 1: '是' }, templet: ea.table.switch },
                    { field: 'default', minWidth: 80, title: '默认值', edit: 'text'  },
                    { field: 'sort', width: 80, title: '排序', edit: 'text' },
                    { field: 'create_time', minWidth: 80, title: '创建时间', search: 'range' },
                    {
                        width: 250,
                        title: '操作',
                        fixed: 'right',
                        templet: ea.table.tool,
                        operat: [
                            'edit',
                            'delete'
                        ]
                    }
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        }
    };
    return Controller;
});